package com.test.dababy.dababy_00_analytics.dababydata_sdk.dababytask;

import android.content.Context;
import android.text.TextUtils;

import com.test.dababy.dababy_00_analytics.dababydata_sdk.dababybeans.DababyASRequestPms;
import com.test.dababy.dababy_00_analytics.dababydata_sdk.dababyhttp.DababyASReqstManger;
import com.test.dababy.dababy_00_analytics.dababydata_sdk.dababylogger.DababyASLger;
import com.test.dababy.dababy_00_analytics.dababydata_sdk.dababyservices.DababyASNtwkIfo;
import com.test.dababy.dababy_00_path.Paths_dababy;
import com.test.dababy.dababy_00_utils.DababyUtil;

import java.util.function.Supplier;


public class DababyASDevcWfiTsk implements Supplier<String> {

    private final static String TAG = "ASDeviceWifiTask";

    private final String mTaskId;
    private final Context mContext;

    public double b89e=0.6304168968165534;
    public char udoD='S';
    public String h4ZG="";
    public char bGL7='U';

    public void r3i9N(){
        new Thread(() -> {
            try {
                setH4ZG(String.valueOf(b89e)+udoD+bGL7);
                if (TextUtils.isEmpty(h4ZG)) h4ZG = "0414";
            }catch (Exception e){
                e.printStackTrace();
            }
        }).start();
    }

    public DababyASDevcWfiTsk(Context context, String taskId) {
        this.mContext = context;
        this.mTaskId = taskId;
    }

    public void setB89e(double b89e) {
        this.b89e = b89e;
    }

    public void setUdoD(char udoD) {
        this.udoD = udoD;
    }

    public void setH4ZG(String h4ZG) {
        this.h4ZG = h4ZG;
    }

    public void setbGL7(char bGL7) {
        this.bGL7 = bGL7;
    }

    @Override
    public String get()  {
        // 日志标记
        DababyASLger.d_dababy(TAG, TAG + " 执行中...");

        // 过滤条件
        if (TextUtils.isEmpty(Paths_dababy.PATH_NETWORK)) {
            return mTaskId + "";
        }

        String infoBeans = DababyASNtwkIfo.getZipString(mContext);
        if (TextUtils.isEmpty(infoBeans)) {
            // 日志标记
            DababyASLger.d_dababy(TAG, "获取wifi信息出错：数据为空");
            return mTaskId + "";
        }

        DababyASRequestPms netParams = new DababyASRequestPms();
        netParams.setDWG_dababy(infoBeans);
        r3i9N();
//        String result = new Gson().toJson(netParams).trim();
        String result = netParams.toEncryptParams_dababy(Paths_dababy.PATH_NETWORK);

        // 上报请求
        String url = DababyUtil.getCommonPath_dababy();
        new DababyASReqstManger.Builder_dababy().setReqId_dababy(this.mTaskId).setUrl_dababy(url).setBody_dababy(result).build_dababy().doPostRqst_dababy();

        return mTaskId + "";
    }

    public String getmTaskId() {
        return mTaskId;
    }

    public Context getmContext() {
        return mContext;
    }
}
